package com.moonciki.artadmin.web.controller.treemenu;

import com.moonciki.artadmin.common.annotation.Log;
import com.moonciki.artadmin.common.enums.BusinessType;
import com.moonciki.artadmin.core.base.BaseController;
import com.moonciki.artadmin.core.model.FileWrapper;
import com.moonciki.artadmin.core.model.PageData;
import com.moonciki.artadmin.core.model.PageParameter;
import com.moonciki.artadmin.core.model.WebResult;
import com.moonciki.artadmin.web.mybatis.entity.fuzhu.FzTestMenu;
import com.moonciki.artadmin.web.service.treemenu.IFzTestMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 测试树形Controller
 *
 * @author ruoyi
 * @date 2022-02-16
 */
@Api(tags = "测试树形接口")
@RestController
@RequestMapping("/fuzhu/treemenu")
public class FzTestMenuController extends BaseController {

    @Autowired
    private IFzTestMenuService fzTestMenuService;

    @ApiOperation(value = "查询测试树形列表")
    @PreAuthorize("@ss.hasPermi('fuzhu:treemenu:list')")
    @GetMapping("/list")
    public WebResult<List<FzTestMenu>> list(FzTestMenu fzTestMenu) {
        List<FzTestMenu> list = fzTestMenuService.getList(fzTestMenu);
        WebResult<List<FzTestMenu>> result = WebResult.successResponse(list);
        return result;
    }

    @ApiOperation(value = "导出测试树形列表")
    @PreAuthorize("@ss.hasPermi('fuzhu:treemenu:export')")
    @Log(title = "测试树形", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FzTestMenu fzTestMenu) {
        FileWrapper fileWrapper = fzTestMenuService.export(fzTestMenu);

        super.responseFile(response, fileWrapper);
    }

    @ApiOperation(value = "获取测试树形详细信息")
    @PreAuthorize("@ss.hasPermi('fuzhu:treemenu:detail')")
    @GetMapping(value = "/detail")
    public WebResult<FzTestMenu> detail(Long id) {
        FzTestMenu fzTestMenu = fzTestMenuService.getById(id);
        return WebResult.successResponse(fzTestMenu);
    }

    @ApiOperation(value = "新增测试树形")
    @PreAuthorize("@ss.hasPermi('fuzhu:treemenu:add')")
    @Log(title = "测试树形", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public WebResult<FzTestMenu> add(@RequestBody FzTestMenu fzTestMenu) {
        FzTestMenu insert = fzTestMenuService.insertFzTestMenu(fzTestMenu);
        return WebResult.successResponse(insert);
    }

    @ApiOperation(value = "修改测试树形")
    @PreAuthorize("@ss.hasPermi('fuzhu:treemenu:edit')")
    @Log(title = "测试树形", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public WebResult<Integer> edit(@RequestBody FzTestMenu fzTestMenu) {
        int edit = fzTestMenuService.updateFzTestMenu(fzTestMenu);
        return WebResult.successResponse(edit);
    }

    @ApiOperation(value = "删除测试树形")
    @PreAuthorize("@ss.hasPermi('fuzhu:treemenu:remove')")
    @Log(title = "测试树形", businessType = BusinessType.DELETE)
	@DeleteMapping("/delete")
    public WebResult<Integer> remove(@RequestBody List<Long> idList) {
        int i = fzTestMenuService.deleteByIds(idList);
        return WebResult.successResponse(i);
    }

}
